﻿@model TopicModel
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form" wid100 lay-filter="">
                        <input asp-for="Id" type="hidden" />
                        <div class="layui-form-item">
                            <u-label asp-for="SystemName" />
                            <div class="layui-input-inline">
                                <u-editor asp-for="SystemName" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <u-label asp-for="Short" />
                            <div class="layui-input-inline">
                                <u-editor asp-for="Short" />
                            </div>
                        </div>
                        @if (Model.Id > 0)
                        {
                            <div class="layui-form-item">
                                <u-label asp-for="Url" />
                                <div class="layui-input-inline" style="margin-top:6px">
                                    <a href="@Model.Url">@Model.Url</a>
                                </div>
                            </div>
                        }
                        <div class="layui-form-item">
                            <u-label asp-for="Title" />
                            <div class="layui-input-inline">
                                <u-editor asp-for="Title" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <u-label asp-for="Body" />
                            <div class="layui-input-inline" style="width:800px;height:420px">
                                <u-editor asp-for="Body" asp-template="UEditor" />
                                <span asp-validation-for="Body"></span>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <u-label asp-for="Published" />
                            <div class="layui-input-inline">
                                <u-bool asp-for="Published" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <u-label asp-for="MetaKeywords" />
                            <div class="layui-input-inline">
                                <u-editor asp-for="MetaKeywords" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <u-label asp-for="MetaDescription" />
                            <div class="layui-input-inline">
                                <u-editor asp-for="MetaDescription" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <u-label asp-for="MetaTitle" />
                            <div class="layui-input-inline">
                                <u-editor asp-for="MetaTitle" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button id="set_system_submit_btn" style="display:none" class="layui-btn" lay-submit lay-filter="set_system_submit_btn">确认保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['index'], function () {
        var $ = layui.$
            , form = layui.form
            ,active = {  }
        form.on('submit(set_system_submit_btn)', function (obj) {
        var index = layer.load(2, { shade: false });
              var field = obj.field; //获取提交的字段
                field.Body = ue.getContent();
                //layer.msg(JSON.stringify(obj.field));
                //提交 Ajax 成功后，关闭当前弹层并重载表格
                $.post('@Url.Action("Edit")', field, function (rep) {
                    if (rep.success == 1) {
                        layer.close(index);
                        layer.msg("保存成功,即将自动关闭", { time: 2 * 1000 }, function () {
                            var iframe_index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            console.log("当前iframe层的索引:" + iframe_index + "==window.name:" + window.name);
                            parent.layer.close(iframe_index); //再执行关闭
                            window.parent.location.reload();
                        });
                    }
                });
                return false;
        });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>

